package com.itcrx.algorithm.recursion;

/**
 * @author NoobMaster69  * @date 2024/6/16 0016 星期日 17:59
 */

/**
 * 递归冒泡排序
 */
public class E04BubbleSort {


    public static void sort(int[] a){
        bubble(a,a.length - 1);
    }
    private static void bubble(int[] a, int j) {
        int x = 0;  //代表 无序和有序的分界点
        if (j == 0) {
            return;
        }
        for (int i = 0; i < j; i++) {
            if (a[i] > a[i + 1]) {
                int t = a[i];
                a[i] = a[i + 1];
                a[i + 1] = t;
                x = i;
            }
        }
        bubble(a,x);
    }
}
